<extend name="Base:main" />
<block name="script">
	<link rel="stylesheet" href="__PUBLIC__/seller/js/uploadify/uploadify.css" />
	<script src="__PUBLIC__/seller/js/uploadify/jquery.uploadify.min.js"></script>
    <script src="__PUBLIC__/seller/js/calendar/WdatePicker.js"></script>
</block>
<block name="content">
    <div class="tpl-content-wrapper">
            <div class="tpl-content-page-title">
                库存供应
            </div>
            <ol class="am-breadcrumb">
                <li><a href="#" class="am-icon-home">首页</a></li>
                <li><a href="#">商品管理</a></li>
                <li class="am-active">库存供应</li>
            </ol>
            <div class="tpl-portlet-components">
                <div class="portlet-title">
                      <div class="caption font-green bold">
                        <span class="am-icon-code"></span>供应详情
                    </div>
                </div>
                <div class="tpl-block ">

                    <div class="am-g tpl-amazeui-form">


                        <div class="am-u-sm-12 am-u-md-9">
                             <form class="am-form am-form-horizontal" ignoreHidden name='myfromSubmit' fun_call="call_fun_check">
                     
							 
							 <div class="am-form-group">
									<label for="user-email" class="am-u-sm-3 am-form-label">商品名称</label>
									<div class="am-u-sm-7 float_left">
										{$goods_info.name}
									</div>
							</div>
							<div class="am-form-group">
									<label for="user-email" class="am-u-sm-3 am-form-label">ean13码</label>
									<div class="am-u-sm-7 float_left">
										{$goods_info.earn13}
									</div>
							</div>
							<div class="am-form-group">
									<label for="user-email" class="am-u-sm-3 am-form-label">供应市场价</label>
									<div class="am-u-sm-4 float_left">
										<input type="text" name="poster[market_price]" id="market_price" datatype="/^[0-9]+(\.[0-9]{1,2})?$/" nullmsg="市场供应价不能为空" errormsg="市场价格格式错误"  value="" >					</div>
							</div>
							<div class="am-form-group">
									<label for="user-email" class="am-u-sm-3 am-form-label">建议销售价</label>
									<div class="am-u-sm-4 float_left">
										<input type="text" name="poster[price]" id="price" datatype="/^[0-9]+(\.[0-9]{1,2})?$/" nullmsg="建议零售价不能为空" errormsg="建议零售价格式错误"  value="" >
									</div>
							</div>
							<div class="am-form-group">
									<label for="user-email" class="am-u-sm-3 am-form-label">是否支持代发</label>
									<div class="am-u-sm-8 float_left">
										<div class="tpl-switch" data-value="{$customer_setting.acting}" data-name="acting"  style="width: 50px;">
											<input type="checkbox" class="ios-switch bigswitch tpl-switch-btn" name="poster[sale_mode][]" value="1" <eq name="customer_setting.acting" value="1">checked</eq>>
											<div class="tpl-switch-btn-view"><div></div></div>
										</div>
									</div>
							</div>
							<span style="display:<eq name="customer_setting.acting" value="1">block<else />none</eq>;" id="acting_setting">
								<div class="am-form-group">
										<label for="user-email" class="am-u-sm-3 am-form-label">一件代发价</label>
										<div class="am-u-sm-2 float_left">
											<input type="text" name="poster[acting_price]" id="acting_price" datatype="/^[0-9]+(\.[0-9]{1,2})?$/" nullmsg="一件代发价不能为空" errormsg="一件代发价格式错误"  value="" >
										</div>
								</div>
							</span>
                            <style>
									.jiage_table_data{ width:600px;}
									.jiage_table_data td{ height:60px; background:#efefef; width:200px; } 
									.jiage_table_data .bt_j{ width:100px; font-size:12px; text-align:right;}
									.jiage_table_data span.Validform_wrong{ float:left}
									.jiage_table_data td label{ font-weight:100; font-size:14px;}
								</style>
								<div class="am-form-group">
										<label for="user-email" class="am-u-sm-3 am-form-label">是否支持锁货</label>
										<div class="am-u-sm-8 float_left">
											<div class="tpl-switch" data-name="lock" data-value="{$customer_setting.lock}" style="width: 50px;">
												<input type="checkbox" class="ios-switch bigswitch tpl-switch-btn" name="poster[sale_mode][]" value="2" <eq name="customer_setting.lock" value="1">checked</eq>>
												<div class="tpl-switch-btn-view"><div></div></div>
											</div>
										</div>
								</div>
								<span style="display:<eq name="customer_setting.lock" value="1">block<else />none</eq>" id="lock_setting">
									<div class="am-form-group">
											<label for="user-email" class="am-u-sm-3 am-form-label">锁货价设置</label>
											<div class="am-u-sm-8 float_left">
												<table class="jiage_table_data">
													<tr>
														<td class="bt_j" valign="middle">锁货价&nbsp;&nbsp;&nbsp;</td>
														<td><input type="text" name="poster[lock_price]" id="lock_price" style="width:100px;" datatype="/^[0-9]+(\.[0-9]{1,2})?$/" nullmsg="锁货价不能为空" errormsg="锁货价格式错误"  value="" ></td>
														<td class="bt_j" valign="middle">最低锁货量&nbsp;&nbsp;&nbsp;</td>
														<td><input type="text" name="poster[lock_start_num]" id="lock_start_num" size="10" style="width:100px;" datatype="/^[0-9]+$/" nullmsg="最低锁货量不能为空" errormsg="最低锁货量格式错误"  value="" ></td>
													</tr>
													<tr>
														<td class="bt_j" valign="middle">每增加&nbsp;&nbsp;&nbsp;</td>
														<td><input type="text" name="poster[inc_lock_num]" id="inc_lock_num" size="10" style="width:100px;" datatype="/^[0-9]+$/" nullmsg="增加数量不能为空" errormsg="格式错误"  value="" ></td>
														<td class="bt_j" valign="middle">单价减少&nbsp;&nbsp;&nbsp;</td>
														<td><input type="text" name="poster[inc_lock_price]" id="inc_lock_price" style="width:100px;" datatype="/^[0-9]+(\.[0-9]{1,2})?$/" nullmsg="增加金额不能为空" errormsg="格式错误"  value="" ></td>
													</tr>
													<tr>
														<td class="bt_j" valign="middle">最低单价&nbsp;&nbsp;&nbsp;</td>
														<td  colspan="3"><input type="text" name="poster[lock_small_price]" id="lock_small_price" size="10" style="width:100px;" datatype="/^[0-9]+(\.[0-9]{1,2})?$/" nullmsg="最低单价不能为空" errormsg="格式错误"  value="" ></td>
													</tr>
												</table>
												
											</div>
											
									</div>
									<div class="am-form-group">
										<label for="user-email" class="am-u-sm-3 am-form-label">锁货付款方式</label>
										<div class="am-u-sm-8 float_left">
											<table class="jiage_table_data">
												<tr>
													<td class="bt_j" valign="middle">类型&nbsp;&nbsp;&nbsp;</td>
													<td colspan="3">&nbsp;&nbsp;&nbsp;&nbsp;<label><input type="radio" value="1" checked name="poster[lock_pay_type]" id="pay_type_s"/> 一次付款</label>&nbsp;&nbsp;&nbsp;&nbsp;<label><input type="radio" value="2" name="poster[lock_pay_type]" id="pay_type_s"/> 两次付款</label>&nbsp;&nbsp;&nbsp;&nbsp;<label><input type="radio" value="3" name="poster[lock_pay_type]" id="pay_type_s"/> 三次付款</label></td>
												</tr>
												<tr style="display:none;">
													<td class="bt_j" valign="middle">收货支付&nbsp;&nbsp;&nbsp;</td>
													<td colspan="3"><input type="text" name="poster[lock_pay_rule][received]" maxlength="2" id="lock_received" style="width:100px;" datatype="/^[0-9]+$/" nullmsg="收货支付比例不能为空" errormsg="格式错误"  value="" ></td>
												</tr>
												<tr style="display:none;">
													<td class="bt_j" valign="middle">锁货支付&nbsp;&nbsp;&nbsp;</td>
													<td><input type="text" name="poster[lock_pay_rule][lock]" maxlength="2" size="10" style="width:100px;" id="lock_lock" datatype="/^[0-9]+$/" nullmsg="锁货支付比例不能为空" errormsg="格式错误"  value="" ></td>
													<td class="bt_j" valign="middle">下单支付&nbsp;&nbsp;&nbsp;</td>
													<td><input type="text" name="poster[lock_pay_rule][down]" size="10" maxlength="2" style="width:100px;" id="lock_down" datatype="/^[0-9]+$/" nullmsg="下单支付比例不能为空" errormsg="格式错误"  value="" ></td>
												</tr>
											</table>
										</div>
								</div>
							</span>
							<div class="am-form-group">
									<label for="user-email" class="am-u-sm-3 am-form-label">是否支持批发</label>
									<div class="am-u-sm-8 float_left">
										<div class="tpl-switch" data-name="wholesale" data-value="{$customer_setting.wholesale}"  style="width: 50px;">
											<input type="checkbox" class="ios-switch bigswitch tpl-switch-btn" name="poster[sale_mode][]" value="3" <eq name="customer_setting.wholesale" value="1">checked</eq>>
											<div class="tpl-switch-btn-view"><div></div></div>
										</div>
									</div>
							</div>
							<span style="display:<eq name="customer_setting.wholesale" value="1">block<else />none</eq>" id="wholesale_setting">
								<div class="am-form-group">
										<label for="user-email" class="am-u-sm-3 am-form-label">批发价设置</label>
										<div class="am-u-sm-8 float_left">
											<table class="jiage_table_data">
												<tr>
													<td class="bt_j" valign="middle">批发价&nbsp;&nbsp;&nbsp;</td>
													<td><input type="text" name="poster[wholesale_price]" id="wholesale_price" datatype="/^[0-9]+(\.[0-9]{1,2})?$/" style="width:100px;" nullmsg="批发价不能为空" errormsg="批发价格式错误"  value="" ></td>
													<td class="bt_j" valign="middle">最低批发量&nbsp;&nbsp;&nbsp;</td>
													<td><input type="text" name="poster[wholesale_start_num]" id="wholesale_start_num" datatype="/^[0-9]+$/" style="width:100px;" nullmsg="最低批发量不能为空" errormsg="最低批发量格式错误"  value="" ></td>
												</tr>
												<tr>
													<td class="bt_j" valign="middle">每增加&nbsp;&nbsp;&nbsp;</td>
													<td><input type="text" name="poster[inc_wholesale_num]" id="lock_price" size="10" style="width:100px;" datatype="/^[0-9]+$/" nullmsg="增加数量不能为空" errormsg="格式错误"  value="" ></td>
													<td class="bt_j" valign="middle">单价减少&nbsp;&nbsp;&nbsp;</td>
													<td><input type="text" name="poster[inc_wholesale_price]" id="lock_start_num" style="width:100px;" size="10" datatype="/^[0-9]+(\.[0-9]{1,2})?$/" nullmsg="增加金额不能为空" errormsg="格式错误"  value="" ></td>
												</tr>
												<tr>
													<td class="bt_j" valign="middle">最低单价&nbsp;&nbsp;&nbsp;</td>
													<td  colspan="3"><input type="text" name="poster[wholesale_small_price]" id="wholesale_small_price" size="10" style="width:100px;" datatype="/^[0-9]+(\.[0-9]{1,2})?$/" nullmsg="最低单价不能为空" errormsg="格式错误"  value="" ></td>
												</tr>
											</table>
										</div>
								</div>
								<div class="am-form-group">
										<label for="user-email" class="am-u-sm-3 am-form-label">批发/代发付款方式</label>
										<div class="am-u-sm-8 float_left">
											<table class="jiage_table_data">
												<tr>
													<td class="bt_j" valign="middle">类型&nbsp;&nbsp;&nbsp;</td>
													<td colspan="3">&nbsp;&nbsp;&nbsp;&nbsp;<label><input type="radio" value="1" checked name="poster[wholesale_pay_type]" id="pay_type_s"/> 一次付款</label>&nbsp;&nbsp;&nbsp;&nbsp;<label><input type="radio" value="2" name="poster[wholesale_pay_type]" id="pay_type_s"/> 两次付款</label></td>
												</tr>
												<tr style="display:none;"></tr>
												<tr style="display:none;">
													<td class="bt_j" valign="middle">下单支付&nbsp;&nbsp;&nbsp;</td>
													<td><input type="text" name="poster[wholesale_pay_rule][down]" maxlength="2" size="10" id="wholesale_down" style="width:100px;" datatype="/^[0-9]+$/" nullmsg="下单支付比例不能为空" errormsg="格式错误"  value="" ></td>
													<td class="bt_j" valign="middle">收货支付&nbsp;&nbsp;&nbsp;</td>
													<td><input type="text" name="poster[wholesale_pay_rule][received]" maxlength="2" id="wholesale_received" style="width:100px;" datatype="/^[0-9]+$/" nullmsg="收货支付比例不能为空" errormsg="格式错误"  value="" ></td>
												</tr>
											</table>
										</div>
								</div>
							</span>
							<div class="am-form-group">
									<label for="user-email" class="am-u-sm-3 am-form-label">供应库存</label>
									<div class="am-u-sm-4 float_left">
										<input type="text" name="poster[stock_num]" id="stock_num" datatype="n" nullmsg="供应库存不能为空" errormsg="供应库存必须为数字"  value="" >
									</div>
							</div>
							<div class="am-form-group">
									<label for="user-email" class="am-u-sm-3 am-form-label">商品库存模式</label>
                                    
									<div class="am-u-sm-9 float_left">
                                    <label class="am-radio-inline">
                                    	<input type="radio"  value="1" name="poster[stock_status]" id="stock_status" checked> 在仓库
                                    </label>
                                    <label class="am-radio-inline">
                                    	<input type="radio" name="poster[stock_status]" id="stock_status" value="2"> 运送途中
                                    </label>
                                    </div>
							</div>
							<div class="am-form-group" style="display:none" id="arrive_time">
									<label for="user-email" class="am-u-sm-3 am-form-label">到达时间</label>
									<div class="am-u-sm-4 float_left">
										<input type="text" name="poster[stock_arrive_time]" id="auth_time" onfocus="WdatePicker({isShowWeek:true})" datatype="*" nullmsg="商品到达时间不能为空"  value="" >
									</div>
							</div>
							<div class="am-form-group">
									<label for="user-email" class="am-u-sm-3 am-form-label">供货仓库</label>
									<div class="am-u-sm-4 float_left">
                                    	<select name="poster[warehouse_id]" datatype="*" nullmsg="请选择您需要绑定的仓库">
											<empty name="warehouse_list">
												<option value="">无仓库数据</option>
											<else />
												<volist name="warehouse_list" id="vo">
												<option value="{$vo.id}">{$vo.name}</option>
												</volist>
											</empty>
                                        </select>
									</div>
							</div>
                             <div class="am-form-group">
									<label for="user-email" class="am-u-sm-3 am-form-label">供应失效类型</label>
                                    
									<div class="am-u-sm-9 float_left">
                                    <label class="am-radio-inline">
                                    	<input type="radio"  value="1" name="poster[is_invalid_type]" id="is_invalid_type" checked> 按库存为0失效
                                    </label>
                                    <label class="am-radio-inline">
                                    	<input type="radio" name="poster[is_invalid_type]" id="is_invalid_type" value="2"> 按时间到期失效
                                    </label>
                                    </div>
							</div>
                            <div class="am-form-group" style="display:none" id="div_invalid_time">
                                    <label for="user-email" class="am-u-sm-3 am-form-label">到期时间</label>
                                    <div class="am-u-sm-4 float_left">
                                        <input type="text" name="poster[invalid_time]" id="invalid_time" onfocus="WdatePicker({isShowWeek:true})" datatype="*" nullmsg="商品失效时间不能为空"  value="" >
                                    </div>
                            </div>
							<div class="am-form-group">
								<div class="am-u-sm-9 am-u-sm-push-3">
									<input type="hidden" value="{$goods_info.id}" name="poster[goods_id]" />
									<button type="submit" class="am-btn am-btn-primary">数据提交</button>
								</div>
							</div>
						</form>
					</div>
				</div>
			</div>

		</div>

        </div>
		<script type="text/javascript">
				$('div.tpl-switch').click(function(){
					var data = $(this).attr('data-value') == 1 ? 0 : 1;
					data == 1 ? $("#" + $(this).attr('data-name') + "_setting").show() : $("#" + $(this).attr('data-name') + "_setting").hide();
					$(this).attr('data-value' , data);
				});
                var goods_type_id = $('#goods_type').val();
                if(goods_type_id){
                    $('#goods_type_id option').each(function(){
                          if( goods_type_id == $(this).attr('value') ) {
                              $(this).attr('selected' , true);
                              return false;
                          } 
                       }); 
                }
				$('input#stock_status').click(function(){
					if($(this).val() == 2 ) {
						$('#arrive_time').show();
					} else {
						$('#arrive_time').hide();
					}
				});
				$('input#is_invalid_type').click(function(){
					if($(this).val() == 2 ) {
						$('#div_invalid_time').show();
					} else {
						$('#div_invalid_time').hide();
					}
				});
				
				$('input#pay_type_s').click(function(){
					var _self = $(this).closest('tr');
					if( $(this).val() == 2 ) {
							_self.next().next().show();
							_self.next().hide();
					} else if( $(this).val() == 3 ) {
							_self.next().show();
							_self.next().next().show();
					} else {
							_self.next().hide();
							_self.next().next().hide();
					}
				});
				
				function call_fun_check() {
					var flag_index = false;
					$('div.tpl-switch').each(function(){
						if( $(this).attr('data-value') == 1 ) {
							flag_index = true;
						}
					});
					
					if( flag_index === false ) {
						error('必须选择一种销售模式');
						return false;
					}
					var lock_down = $('#lock_down').val();
					var lock_lock = $('#lock_lock').val();
					var lock_received = $('#lock_received').val();
					var wholesale_down = $('#wholesale_down').val();
					var wholesale_received = $('#wholesale_received').val();
					if( $('input[name="poster[lock_pay_type]"]:checked').val() == '2' ) {
						if( parseInt( lock_down ) + parseInt( lock_lock ) != 100 ) {
							error('锁货支付比例总和必须为100！');
							return false;
						}
					} else if( $('input[name="poster[lock_pay_type]"]:checked').val() == '3' ) {
						if( parseInt( lock_down ) + parseInt( lock_received ) + parseInt( lock_lock ) != 100 ) {
							error('锁货支付比例总和必须为100！');
							return false;
						}
					}
					if( $('input[name="poster[wholesale_pay_type]"]:checked').val() == '2' ) {
						if( parseInt( wholesale_down ) + parseInt( wholesale_received ) != 100 ) {
							error('批发/代发支付比例总和必须为100！');
							return false;
						}
					}
				}
        </script>
</block>